﻿using System;
using PrismicIOAPI.Web.Common.UI;
using PrismicIOAPI.Web.UI;

namespace PrismicIOAPI.Usage.Example.aspx
{
    public partial class preview : PrismicPage
    {
        protected override void BindControls()
        {
            string queryString = Request.QueryString[ "token" ];
            if( String.IsNullOrEmpty( queryString ) == true )
            {
                Response.Redirect( "~/" );
                return;
            }
            DataSource = PrismicQuery.SEARCH_BY_EMPTY_STRING;
            if( PageDocumentList == null || PageDocumentList.Count == 0 )
            {
                Response.Redirect( "~/" );
                return;
            }
            prismic.Api.Document document = PageDocumentList[ 0 ];
            if( System.String.Compare( document.typ , "default" , System.StringComparison.Ordinal ) == 0 )
            {
                Response.Redirect( "~/default?token=" + queryString );
                return;
            }
            if( System.String.Compare( document.typ , "test" , System.StringComparison.Ordinal ) == 0 )
            {
                Response.Redirect( "~/test?token=" + queryString );
                return;
            }
            if( System.String.Compare( document.typ , "test2" , System.StringComparison.Ordinal ) == 0 )
            {
                Response.Redirect( "~/test2?token=" + queryString );
                return;
            }
            if( System.String.Compare( document.typ , "test3" , System.StringComparison.Ordinal ) == 0 )
            {
                Response.Redirect( "~/test3?token=" + queryString );
                return;
            }
            Response.Redirect( "~/" );
        }
    }
}